<template>
    <div class="child">
        <h3>子组件:弟弟</h3>
        <h4>我的玩具：{{ toy }}</h4>
        <h4>哥哥给我的玩具：{{ present }}</h4>
    </div>
</template>

<script setup lang="ts" name="Child2">
import { ref } from "vue";
import emitter from "@/util/emitter";
const toy = ref('咖宝车神');
const present = ref<string>('')

//订阅send-toy事件，监听任务
emitter.on('send-toy',(value:any)=>{
    present.value = value;
})


</script>

<style scoped>
.child {
    border: 1px solid #ccc;
    padding: 10px;
    margin: 10px 0;
    background-color: #f0f0f0;
}
</style>
